package com.xzq.register;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;

import java.util.List;
import java.util.concurrent.CountDownLatch;

/**
 * @Author xzq
 * @Description //TODO
 * @Date 2021/12/1 18:29
 * @Version 1.0.0
 **/
public class NacosRegister {
    public static void main(String[] args) {
        CountDownLatch countDownLatch = new CountDownLatch(1);
        try {
            NamingService namingService = NamingFactory.createNamingService("192.168.5.56:8848");
            namingService.registerInstance("11111", "127.0.0.1", 9999);
            namingService.registerInstance("11111", "127.0.0.2", 9998);
            List<Instance> list = namingService.getAllInstances("11111");
            System.out.println(list);
            countDownLatch.await();
        } catch (NacosException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}
